<?php

if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Relationship extends CI_Controller {

	function __construct() {
		parent::__construct();
	}

	public function show_html() {
		$html["ref_client_verify_code"] = $this -> input -> post('ref_client_verify_code');
		$html["i"] = $this -> input -> post('count');
		$this -> load -> view('client/relationship_table', $html);

	}

	public function update_relationship_submit() {

		$this->load->model("client_model");

		//print_r($_POST);

		foreach ($_POST["relation"] as $key => $data) {


			if(!empty($data["client_relationship_id"])){

				//更新
				$this -> client_model -> update_contact_submit($data, $data["client_relationship_id"]);

			}else{

				//新增
				$this -> client_model -> insert_relationship($data , $_POST["ref_client_verify_code"]);

			}

		}

	}




	//新增聯絡人
	public function insert_relationship_submit() {
                //print_r($_POST);
		$this -> load -> model("client_model");
		$verify_code = $_POST["ref_client_verify_code"];

		foreach ($_POST["relation"] as $val => $data) {
			$this -> client_model -> insert_relationship($data, $verify_code);
		}

	}

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
